var InformDetails = {
	inform_id: fnBase.splitURL()['inform_id'],
	user_id: fnBase.splitURL()['user_id'],
	user_name: fnBase.splitURL()['user_name'],
	user_img: fnBase.splitURL()['user_img'],
	page: 1,
	replyThis:{},
	//初始化事件
	init: function() {
		this.AddEvent(); //事件
		this.forAddEvent();
		this.commentList();
	},
	//初始化点击事件委托
	initClick: function(e) {
		var list = document.getElementById('InformReplyList');
		var boxs = list.children;
		var boxsLength = boxs.length;
		for(var i = 0; i < boxsLength; i++) {
			boxs[i].onclick = function(e) {
				e = e || window.event;
				var el = e.srcElement ? e.srcElement : e.target;
				switch(el.className) {
					case 'second-reply':
						//三级回复
						InformDetails.setUpTextareaBox(el);
						break;
					case 'post-comments-txt':
						//二级回复
						InformDetails.setUpTextareaBox(el);
						break;
				}
			};
		}
	},
	AddEvent: function() {
		
	},
	forAddEvent: function() {
		//点回复数 评论
		$('#InformReplyList').bind('click').on('click', '.comment-btn', function() {
			var el = $(this);
			InformDetails.setUpTextareaBox(el);
		});
		$('#InformReplyList').bind('click').on('click', '.post-comments-function', function() {
			var _this = $(this);
			InformDetails.commentsReply(_this);
		});
	},
	commentList: function() {
		var twocommentStr = '';
		twocommentStr +='<div class="post-comments-child">' +
									'<p source_id="3" user_name="user_name" user_id="user_id" inform_reply_id="inform_reply_id" class="second-reply"><span class="nick-go-individual" user_id=" user_id">Nicole：</span>评论内容</p></div>';
		$('.post-comments-child-wrap').append(twocommentSt);
	},	
	//更多二级评论
	commentsReply: function(_this) {
		var inform_reply_id = _this.attr('inform_reply_id');
		var page = _this.attr('page');
		var user_id = _this.attr('user_id');
		var status = true;
		var twocommentStr = '';
		twocommentStr += '<div class="post-comments-child">' +
									'<p source_id="3" user_name="user_name" user_id="user_id" inform_reply_id="inform_reply_id" class="second-reply"><span class="spancolor">回复</span>' +
									'<span user_id="user_id" class="replynick-go-individual">Nicole</span>评论内容</p>' +
									'</div>';
		_this.prev().append(twocommentStr);	
	},
	//真输入框
	setUpTextareaBox: function(el) { //输入框盒子
		var _this = $(el);
		InformDetails.replyThis=_this; //回复的this 对象
		var source = _this.attr('source_id'); //判断是几级回复
		var getInformUser = 0; //一级回复的文章user_ID
		var parent_id = source == 1 ? 0 : _this.attr('inform_reply_id');
		var reply_user_id = source == 1 ? getInformUser : _this.attr('user_id');
		var reply_user_name = source == 1 ? InformDetails.user_name : _this.attr('user_name');
		//给原生穿餐
		window.control.showCommentDialog(source,parent_id,reply_user_id,reply_user_name);
		// weakupkeyboard(source,parent_id,reply_user_id,reply_user_name);
	},
	//更多二级评论
	commentsReply: function(_this) {
		var inform_reply_id = _this.attr('inform_reply_id');
		var page = _this.attr('page');
		var user_id = _this.attr('user_id');
		var status = true;
	},
	//获取原生参数内容 
	getTextareaBox:function(source,parent_id,reply_user_id,reply_user_name,contentVal){
		InformDetails.initClick();
		var contentVal=contentVal;  
		var source=source;
		var parent_id =parent_id;
		var reply_user_id=reply_user_id;
		var reply_user_name=reply_user_name;
		var _this=InformDetails.replyThis;
		var content = contentVal;
		content = content.replace(/\n/g, "<br/>");
		content = content.replace(/\s/g, "&nbsp;");
		alert(content);
		var str = '<div class="post-comments-child">' +
				  '<p source_id="3" user_name="Nicole" user_id="2" inform_reply_id="1" class="second-reply"><span user_id="2"  class="nick-go-individual">Nicole</span>' +
				  '<span class="spancolor">回复</span><span user_id="' + reply_user_id + '" class="replynick-go-individual">' + reply_user_name + '：</span>' +
					content + '</p></div>';
		var myLi = _this.parent().parent().find('.post-comments-child-wrap');
		myLi.append(str);
	},
}
$(document).ready(function(){
	InformDetails.init();
});
window.onload=function(){
	var reply_user_name= fnBase.splitURL()['user_name'];
	var reply= fnBase.splitURL()['reply'];
	if(reply==1){
		// weakupkeyboard(1,0,0,reply_user_name);
		window.control.showCommentDialog(1,0,0,reply_user_name);
	}
};
